﻿using Microsoft.AspNetCore.Mvc;
using NUnit.Framework;

namespace MVC高级教程.Controllers
{
    [TestFixture]
    public class ConfigurationController : Controller
    {
        private readonly IConfiguration _configuration;


        //通过构造函数注入
        public ConfigurationController(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        public IActionResult Index()
        {
            return View();
        }



        [Test]
        public void ConfigurationTest()
        {
            //在mvc core中想操作配置文件，需要Microsoft.Extensions.Configuraion包，所以要先引入包
            string connStr= _configuration.GetConnectionString("sqlServerConn")?.ToString();
        }
    }
}
